Skip to content

Conversation

@noot
Copy link
Contributor

@noot noot commented Oct 6, 2025

📝 Summary

  • implement sync and execution of flashblocks received over p2p

instructions for local testing with builder-playground, 1 builder building and 1 builder syncing:

  1. checkout modified builder-playground branch: cd builder-playground && git checkout noot/multi-builder
  2. checkout and build this branch: cd op-rbuilder && git checkout noot/p2p-sync && cargo build
  3. run builder-playground:
sudo rm -rf ~/.playground ~/.local/share/reth && go run main.go cook opstack --flashblocks --external-builder http://host.docker.internal:4444 --flashblocks-builder ws://host.docker.internal:1111 --base-overlay
  1. check that the sync-only node has started: docker logs devnet-op-rbuilder-sync-only-1 -f
  2. run builder that will build:
./target/debug/op-rbuilder node --chain $HOME/.playground/devnet/l2-genesis.json --http --http.port 2222 --authrpc.port 4444 --authrpc.jwtsecret $HOME/.playground/devnet/jwtsecret --port 30333 --disable-discovery --rollup.builder-secret-key 59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d --trusted-peers enode://79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8@127.0.0.1:30304 --authrpc.addr 0.0.0.0 --flashblocks.enabled --flashblocks.addr 172.17.0.1 --flashblocks.port 1111 --rollup.chain-block-time 2000 --flashblocks.p2p_enabled

you should see logs showing that the nodes connected and that flashblocks are syncing and successfully executing and being added to the canonical chain:

2025-10-15T18:52:31.442158Z  INFO executing flashblock header=Header { parent_hash: 0x70285e5ea71a4e7a3f8201ad26f3e9d56fa7c107b829577ed62f81e50134dcaf, ommers_hash: 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, beneficiary: 0x4200000000000000000000000000000000000011, state_root: 0x468f6ad3315f8435ef691e752eb3420313c0709d9c10cd5231d069e61ec4c36f, transactions_root: 0xa0ba654a54295a9730299eccbdbda4e485729cac1020d47e63ed7322f61455d9, receipts_root: 0x078cb07a71cd0774760b0d2ef9d538699f8a5a90269eb293f79e6978968225ad, logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, difficulty: 0, number: 25, gas_limit: 60000000, gas_used: 73498, timestamp: 1760554353, extra_data: 0x00000000fa00000006, mix_hash: 0x0130f5ed8cefc24088a9b58715b709e975ce4fd6e4c53d5fefb2a0435b1e9cfc, nonce: 0x0000000000000000, base_fee_per_gas: Some(905213509), withdrawals_root: Some(0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421), blob_gas_used: Some(0), excess_blob_gas: Some(0), parent_beacon_block_root: Some(0x59fe6ce059192b2ce5d0e83a5b149f88d5d10e3d5d69713da1784eccbd6c2d9d), requests_hash: None }
2025-10-15T18:52:31.442901Z  INFO successfully executed flashblock header=Header { parent_hash: 0x70285e5ea71a4e7a3f8201ad26f3e9d56fa7c107b829577ed62f81e50134dcaf, ommers_hash: 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347, beneficiary: 0x4200000000000000000000000000000000000011, state_root: 0x468f6ad3315f8435ef691e752eb3420313c0709d9c10cd5231d069e61ec4c36f, transactions_root: 0xa0ba654a54295a9730299eccbdbda4e485729cac1020d47e63ed7322f61455d9, receipts_root: 0x078cb07a71cd0774760b0d2ef9d538699f8a5a90269eb293f79e6978968225ad, logs_bloom: 0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, difficulty: 0, number: 25, gas_limit: 60000000, gas_used: 73498, timestamp: 1760554353, extra_data: 0x00000000fa00000006, mix_hash: 0x0130f5ed8cefc24088a9b58715b709e975ce4fd6e4c53d5fefb2a0435b1e9cfc, nonce: 0x0000000000000000, base_fee_per_gas: Some(905213509), withdrawals_root: Some(0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421), blob_gas_used: Some(0), excess_blob_gas: Some(0), parent_beacon_block_root: Some(0x59fe6ce059192b2ce5d0e83a5b149f88d5d10e3d5d69713da1784eccbd6c2d9d), requests_hash: None }
2025-10-15T18:52:31.443200Z  INFO Block added to canonical chain number=25 hash=0x17daba1d7d7386a5af8cb0cff6dac93b4ef310c9ffc88df6ce9af04b59568700 peers=1 txs=2 gas_used=73.50Kgas gas_throughput=5.57Ggas/second gas_limit=60.00Mgas full=0.1% base_fee=0.91Gwei blobs=0 excess_blobs=0 elapsed=13.19µs

💡 Motivation and Context

--- see #275

✅ I have completed the following steps:

  • Run make lint
  • Run make test
  • Added tests (if applicable)

@noot noot requested a review from 0x416e746f6e as a code owner October 16, 2025 15:30
@avalonche
Copy link
Collaborator

please test with load with contender just to make sure there's no regression in the caching (notably the latencies for get payload, new payload etc are not affected under load)

}
}
debug!(
info!(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe debug?

..
} => {
debug!("connection closed with peer {peer_id}: {cause:?}");
info!("connection closed with peer {peer_id}: {cause:?}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

continue;
}

tracing::info!("mDNS discovered peer {peer_id} at {multiaddr}");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug?

Base automatically changed from noot/p2p to main October 27, 2025 21:04
Copilot AI review requested due to automatic review settings October 27, 2025 21:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements peer-to-peer synchronization and execution of flashblocks, allowing builder nodes to receive and execute flashblocks from other builders in addition to building their own.

Key changes:

  • Added flashblock execution logic for synced blocks with validation against expected block hashes
  • Enhanced P2P behavior to automatically dial discovered mDNS peers and prevent duplicate connections
  • Added new metrics to distinguish between built and synced flashblocks

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
crates/p2p/src/outgoing.rs Enhanced error handling for message broadcasting and changed logging level from debug to info
crates/p2p/src/lib.rs Added automatic dialing of mDNS discovered peers and updated event handling to pass swarm reference
crates/p2p/src/behaviour.rs Modified mDNS event handling to dial discovered peers if not already connected
crates/op-rbuilder/src/tests/flashblocks.rs Reformatted test configuration structs (whitespace changes only)
crates/op-rbuilder/src/metrics.rs Added metrics for synced blocks and separated invalid block counters for built vs synced blocks
crates/op-rbuilder/src/builders/flashblocks/service.rs Created syncer context and integrated it with payload handler
crates/op-rbuilder/src/builders/flashblocks/payload_handler.rs Implemented complete flashblock execution and validation logic for synced payloads
crates/op-rbuilder/src/builders/flashblocks/payload.rs Updated metrics initialization and reference to use shared instance
crates/op-rbuilder/src/builders/flashblocks/mod.rs Added ctx module declaration
crates/op-rbuilder/src/builders/flashblocks/ctx.rs New file defining syncer context for flashblock execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@noot noot requested a review from SozinM October 27, 2025 21:34
Copilot AI review requested due to automatic review settings October 27, 2025 21:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

crates/op-rbuilder/src/builders/flashblocks/payload_handler.rs:1

  • The TODO comment indicates uncertainty about cancellation token usage. If the token is truly unused due to reth's task_executor, consider documenting why it's still being created and passed through the system, or evaluate if it should be removed.
use crate::{

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@SozinM SozinM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@noot noot merged commit 440183b into main Oct 28, 2025
4 checks passed
@noot noot deleted the noot/p2p-sync branch October 28, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants